A good answer might be:

  1. How will the user indicate if group has no data in it?
    • By starting the group with a count of "0".
  2. Will the program run correctly if either group has no data in it?
    • Yes—the loop body for that group will not execute.

Sentinel Controlled Input Loop

Here is what the data should look like if group "A" has no data in it, and group "B" has four test scores in it:

0          
4          
78
82
91
84

Recall that one of the types of loops is a "sentinel" controlled loop, where a special input value indicates that there is no more data. This idea can be used with input files as well. Say that your program is to add up the integers in a file of data. The integers are all expected to be positive integers, so the sentinel value can be any negative integer. Here is a sample input file:

78
82
91
84
-1

The program should average the first four integers in this file (and not include the "-1" in the average.)

QUESTION 13:

  1. What is an advantage of this form of input file?
  2. What is a disadvantage of this form of input file?